﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.OleDb;
using System.Data;

public partial class IzbrisiGrad : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string conString = ConfigurationManager.ConnectionStrings["link"].ConnectionString; //postavuvame "adresa" do bazata
        OleDbConnection conn = new OleDbConnection(conString); //otvarame konekcija
        OleDbCommand com = new OleDbCommand();
        com.Connection = conn;
        com.CommandType = CommandType.Text;

        conn.Open();

        for (int i = 0; i < CheckBoxList1.Items.Count; i++)
        {
            if (CheckBoxList1.Items[i].Selected)
            {
                com.CommandText = "delete * from Gradovi where IdGrad=" + CheckBoxList1.Items[i].Value.ToString();
                com.ExecuteNonQuery();
            }
        }
        conn.Close();
        Response.Redirect("MeniAdmin.aspx");
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("MeniAdmin.aspx");
    }
}